package ru.st.selenium.pages;

import static org.openqa.selenium.support.ui.ExpectedConditions.presenceOfElementLocated;


import org.openqa.selenium.By;
import org.openqa.selenium.TimeoutException;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

public class WampServerHomepage extends AnyPage{

	
	@FindBy (xpath = "//ul[@class='projects']//li//a[contains(text(),'php4dvd')]")
	private WebElement project;
	
	
	public WampServerHomepage(PageManager pages) {
		super(pages);
	}
	
	 public WampServerHomepage ensurePageLoaded() {
		    
		    super.ensurePageLoaded();
		    wait.until(presenceOfElementLocated(By.xpath("//ul[@class='projects']//li//a[contains(text(),'php4dvd')]")));		   	   
		    return this;
		    
		  }
	 
	 public LoginPage openProject(){
				 
		        project.click();
	
		        try
		        {
		        	WebDriverWait wait = new WebDriverWait(driver,30);
		        
				
				wait.until(ExpectedConditions.presenceOfElementLocated(By.id("username")));
				
				return new LoginPage(pages);
		        }
		        catch (TimeoutException e){
				
		        	return null;
			
	 }
	
}
}
